﻿using Abp.Domain.Repositories;
using AppFramework.DinosaursParkMes.TicketTask.DTO;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AppFramework.DinosaursParkMes.TicketTask
{
    /// <summary>
    /// 成员管理
    /// </summary>
    public class MemberinfoAppService : AppFrameworkAppServiceBase, IMemberinfoAppService
    {
        private readonly IRepository<Memberinfo> repository;
        private readonly IRepository<TeamorGroupinfo> reamorGroupinforepository;

        public MemberinfoAppService(IRepository<Memberinfo> repository, IRepository<TeamorGroupinfo> reamorGroupinforepository = null)
        {
            this.repository = repository;
            this.reamorGroupinforepository = reamorGroupinforepository;
        }
        /// <summary>
        /// 根据班组获取负责人
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet,Route("SelectMember")]
        public async Task<List<MemberResponseDTO>> SelectMember(int id)
        {
            var list = from a in repository.GetAll()
                       join b in reamorGroupinforepository.GetAll() on a.Classid equals b.Id
                       where b.Id==id
                       select new MemberResponseDTO
                       {
                           Membername= a.Membername,
                       };
            return await list.ToListAsync();
        }
    }
}
